#ifndef __XML_SENDER_TASK_2BF6561B_72E6_49e4_AB5A_23F26D9B8E62
#define __XML_SENDER_TASK_2BF6561B_72E6_49e4_AB5A_23F26D9B8E62
#pragma once
#include "talk/xmpp/jid.h"
#include "talk/base/task.h"
#include "talk/xmpp/xmppengine.h"
#include "talk/xmpp/xmpptask.h"
#include "talk/xmllite/qname.h"
#include <string>
#include <vector>


namespace str
{
	enum PackageType
	{
		PACKAGE_TYPE_PRESENT,
		PACKAGE_TYPE_PING,
		PACKAGE_TYPE_REQUEST_UPNP_ONE_PORT,
		PACKAGE_TYPE_RESPONSE_UPNP_ONE_PORT,
		PACKAGE_TYPE_REQUESY_INFO,
		PACKAGE_TYPE_REQUESY_IPLIST,
		PACKAGE_TYPE_REQUESY_P2P_IPLIST,
		PACKAGE_TYPE_RESPONSE_INFO,
		PACKAGE_TYPE_RESPONSE_IPLIST,
		PACKAGE_TYPE_RESPONSE_P2P_IPLIST,
	};

	static const std::string NS_PING("urn:xmpp:ping");
	const buzz::QName QN_PING(NS_PING, "ping");

	struct stConnect{
		unsigned int	ip;
		unsigned int	version;
		unsigned short	type;	//type defined as enum ConnectType above
		unsigned short	ports[7];
	};

	class CXMLSenderTask : public buzz::XmppTask
	{
	public:
		CXMLSenderTask(XmppTaskParentInterface* parent,const std::string &cn="", int type = PACKAGE_TYPE_PRESENT );
		virtual ~CXMLSenderTask();

		buzz::XmppReturnStatus SendToXmppServer( );
		buzz::XmppReturnStatus SendToJID(const std::string & toJid);

		virtual int ProcessStart();
		virtual int ProcessResponse();
		virtual bool HandleStanza(const buzz::XmlElement* stanza){ return false; }
		
		void SetType(int type) { m_iType = type; }
		void SetMask(int mask) { m_requestMask = mask; }
		void SetTaskName(const std::string &name) { m_strTaskName = name; }
		void SetConnects(const std::vector<stConnect> & obj) { m_vecConnectOptEx = obj; }

	private:
		buzz::XmlElement * GenerateXml();
		buzz::XmlElement * GeneratePresentXml();
		buzz::XmlElement * GeneratePingXml();

		talk_base::scoped_ptr<buzz::XmlElement> stanza_;
		bool done_;
		std::string m_strComputerName;
		std::string m_strTaskName;
		std::string m_strTo;
		int m_iType;

		std::vector<stConnect> m_vecConnectOptEx;
		int m_requestMask;
	};
}


#endif //__XML_SENDER_TASK_2BF6561B_72E6_49e4_AB5A_23F26D9B8E62